
using System;

namespace MvvmFx.Common.ViewModels
{
    /// <summary>
    /// Event argument carrying a <see cref="ViewModelBase"/> item
    /// </summary>
    /// <typeparam name="T">The event argument of base type <see cref="ViewModelBase"/></typeparam>
    public class ItemEventArgs<T> : EventArgs where T : ViewModelBase
    {
        /// <summary>
        /// The lt;T&gt; item stored with the event args field. 
        /// </summary>
        private readonly T item;

        /// <summary>
        /// The old start starting index field.
        /// </summary>
        private readonly System.Int32 oldStartingIndex;

        /// <summary>
        /// The new starting index field.
        /// </summary>
        private readonly System.Int32 newStartingIndex;

        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEventArgs{T}"/> class.
        /// </summary>
        /// <param name="item">The item&lt;T&gt;</param>
        [System.Diagnostics.DebuggerStepThrough]
        public ItemEventArgs(T item)
        {
            this.item = item;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEventArgs{T}"/> class.
        /// </summary>
        /// <param name="item">The item lt;T&gt; to add to the argument.</param>
        /// <param name="oldStartingIndex">The old starting index to add to the argument.</param>
        /// <param name="newStartingIndex">The new starting index to add to the argument.</param>
        [System.Diagnostics.DebuggerStepThrough]
        public ItemEventArgs(T item, int oldStartingIndex, int newStartingIndex)
        {
            this.item = item;

            this.oldStartingIndex = oldStartingIndex;
            this.newStartingIndex = newStartingIndex;
        }

        /// <summary>
        /// Gets the value of the <see cref="ViewModelBase"/> Item property.
        /// </summary>
        public T Item
        {
            get { return this.item; }
        }

        /// <summary>
        /// Gets the value of the <see cref="OldStartingIndex"/> property.
        /// </summary>
        public Int32 OldStartingIndex
        {
            get { return this.oldStartingIndex; }
        }

        /// <summary>
        /// Gets the value of the <see cref="NewStartingIndex"/> property.
        /// </summary>
        public Int32 NewStartingIndex
        {
            get { return this.newStartingIndex; }
        }
    }

    /// <summary>
    /// Event argument carrying a <see cref="ViewModelBase"/> item
    /// </summary>
    public class ItemEventArgs : EventArgs
    {
        /// <summary>
        /// The item field.
        /// </summary>
        private readonly object item;

        /// <summary>
        /// Initializes a new instance of the <see cref="ItemEventArgs"/> class.
        /// </summary>
        /// <param name="item">The item to add to the argument.</param>
        [System.Diagnostics.DebuggerStepThrough]
        public ItemEventArgs(object item)
        {
            this.item = item;
        }

        /// <summary>
        /// Gets the value of the <see cref="Item"/> property.
        /// </summary>
        public object Item
        {
            get { return this.item; }
        }
    }

    /// <summary>
    /// Cancelable cvent argument carrying a <see cref="ViewModelBase"/> item
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class CancelItemEventArgs<T> : ItemEventArgs<T> where T : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CancelItemEventArgs&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="item">The item&lt;T&gt;</param>
        public CancelItemEventArgs(T item)
            : base(item) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="CancelItemEventArgs&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancel">if set to <c>true</c> [cancel].</param>
        public CancelItemEventArgs(T item, bool cancel)
            : base(item)
        {
            this.Cancel = cancel;
        }

        /// <summary>
        /// Gets or sets the value of the cancel flag.
        /// </summary>
        public bool Cancel { get; set; }
    }
}